Release 10.1A: OpenEdge Development:
Progress 4GL Handbook


Progress 4GL Functions

This section provides a quick summary of some of the most useful functions available to you in the 4GL:

Other sections of the book look at functions that convert data values and otherwise operate as part of data retrieval.

Date functions

Table 2–5 describes functions that return or operate on data values.

Table 2–5: Date functions
Function
Arguments
Returned value
DAY
DATE
INTEGER — The day of the month.
MONTH
DATE
INTEGER — The month of the year.
YEAR
DATE
INTEGER — The year.
WEEKDAY
DATE
INTEGER — The day of the week, starting with 1 for Sunday.
TIME
none
INTEGER — The number of seconds since midnight.
TODAY
none
DATE — Today’s date.

Functions that convert data are discussed in later chapters. An example of one for now is the STRING function.

To see how you can use the STRING function to convert the time into a meaningful display:

  1. In the Procedure Editor, select File New Procedure to open a new procedure window.
  2. Enter the following code, which applies the STRING function to the result of the TIME function, along with the special formatting characters HH (hour), MM (minute), and SS (second):
  3. DISPLAY STRING(TIME, “HH:MM:SS”). 
    

  4. Press F2:
List functions

The functions described in Table 2–6 operate on lists. All the list functions are one-based, that is, the first element in a list is considered to be element 1, not 0.

Table 2–6: List functions
Function
Arguments
Returned value
ENTRY
element AS INTEGER, list AS CHAR, delimiter AS CHAR
CHARACTER — The nth element in a delimited list, where n is the value of the element argument. The delimiter is optional and defaults to comma.
LOOKUP
element AS CHAR, list AS CHAR, delimiter as CHAR
INTEGER — The numeric (one-based) location of the element within the list. The delimiter is optional and defaults to a comma. The function returns 0 if the element is not in the list.

4GL string manipulation functions

The functions described in Table 2–7 operate on character strings.

Table 2–7: 4GL string manipulation functions
Function
Arguments
Returned value
FILL
expression AS CHAR, repeat-count AS INTEGER
CHARACTER — A character string made up of the expression repeated repeat-count times.
INDEX
source AS CHAR, target AS CHAR, starting-point AS INTEGER
INTEGER — The position of the first occurrence of the target string within the source string, relative to the starting-point. The starting-point is optional and defaults to 1 (the beginning of the string).
LEFT-TRIM
string AS CHAR, trim-chars AS CHAR
CHARACTER — The input string, with the trim-chars removed from the beginning of the string. The trim-chars argument is optional, and defaults to any white space (spaces, tabs, carriage returns, and line feeds).
LENGTH
string AS CHAR, type AS CHAR
INTEGER — The number of characters, bytes, or columns in the string. The type is optional and defaults to CHARACTER. Other possible values for this argument are RAW, which makes the function return the number of bytes in the string, and COLUMN, which causes it to return the number of display or print character-columns. These latter two types are useful for manipulating strings that might contain double-byte characters representing characters in non-European languages.
R-INDEX
source AS CHAR, target AS CHAR, starting-point AS INTEGER
INTEGER — The position of the target string within the source string, but with the search starting at the end of the string rather than the beginning. The position, however, is counted starting at the left. This function is useful for returning the right-most (last) occurrence of the source substring. The starting-point is optional and defaults to 1.
REPLACE
source AS CHAR, from-string AS CHAR, to-string AS CHAR
CHARACTER — The source string with every occurrence of the from-string replaced by the to-string.
RIGHT-TRIM
string AS CHAR.trim-chars AS 
CHAR 
CHARACTER — The input string with the trim-chars removed from the end of the string. The trim-chars argument is optional and defaults to all white space.
SUBSTRING
source AS CHAR, position AS INTEGER, length AS INTEGER, type AS CHARACTER
CHARACTER — The substring of the source string beginning at the position. The length is optional and specifies the (maximum) length to return. The default is the remaining length of the string starting at position. The type is also optional and has same values as for the LENGTH function.
TRIM
string AS CHAR. trim-chars AS CHAR
CHARACTER — The input string with the trim-chars removed from both the beginning and the end of the string. The trim-chars argument is optional and defaults to all white space.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095